package kr.saeildamil.androidstudy_second.cp;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class ProductDBHelper extends SQLiteOpenHelper {

	public ProductDBHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
		
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		String sql = "create table product(_id INTEGER PRIMARY KEY AUTOINCREMENT," +
					"name TEXT, price INTEGER);";		
		db.execSQL(sql);
		db.execSQL("INSERT INTO product VALUES (null, '오징어 땅콩', 900);");
		db.execSQL("INSERT INTO product VALUES (null, '농심 포테이토 칩', 2000);");
		db.execSQL("INSERT INTO product VALUES (null, '로보트 태권 V', 1000);");
		db.execSQL("INSERT INTO product VALUES (null, '꼬마 자동차 붕붕', 1500);");
		db.execSQL("INSERT INTO product VALUES (null, '윈도우즈 API 정복', 32000);");
		db.execSQL("INSERT INTO product VALUES (null, '롯데 인벤스 아파트', 190000000);");
		db.execSQL("INSERT INTO product VALUES (null, '88 라이트', 1900);");
		db.execSQL("INSERT INTO product VALUES (null, '프라이드 1.6 CVVT 골드', 8900000);");
		db.execSQL("INSERT INTO product VALUES (null, '캐리비안 베이 입장권', 25000);");

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS product");
		onCreate(db);

	}

}
